import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '订单号',
    align:"center",
    dataIndex: 'orderNumber',
    resizable: true,
  },
  {
    title: '收款日期',
    align:"center",
    dataIndex: 'collectionDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
    resizable: true,
    width:100
  },
  {
    title: '款项类型',
    align:"center",
    dataIndex: 'paymentType_dictText',
    resizable: true,
    width:100
  },
  {
    title: '收款金额',
    align:"center",
    dataIndex: 'amountCollected',
    resizable: true,
    width:100
  },
  {
    title: '付款方式',
    align:"center",
    dataIndex: 'paymentMethod_dictText',
    resizable: true,
    width:100
  },
  {
    title: '扫码支付',
    align:"center",
    // width:"100px",
    dataIndex: 'scanCodePayUrl',
    customRender:render.renderImage,
    resizable: true,
  },
  {
    title: '交易状态',
    align:"center",
    dataIndex: 'tradeState',
    resizable: true,
    width:100
  },
  {
    title: '交易状态描述',
    align:"center",
    dataIndex: 'tradeStateDesc',
    resizable: true,
  },
  {
    title: '收款人',
    align:"center",
    dataIndex: 'createBy',
    resizable: true,
    width:100
  },
  {
    title: '收款凭证',
    align:"center",
    dataIndex: 'receiptVoucher',
    customRender:render.renderImage,
    resizable: true,
  },
  {
    title: '到账状态',
    align:"center",
    sorter: true,
    dataIndex: 'receiptStatus_dictText',
    resizable: true,
    width:100
  },
  {
    title: '当前流程处理人',
    align:"center",
    dataIndex: 'processInitiator',
    resizable: true,
  },
  {
    title: '流程状态',
    align:"center",
    dataIndex: 'processStatus',
    resizable: true,
    width:100
  },
  {
    title: '流程进展',
    align:"center",
    dataIndex: 'processProgress',
    resizable: true,
    width:150
  },
  /* {
   title: '流程启动时间',
   align:"center",
   dataIndex: 'processStartTime'
  },
  {
   title: '流程结束时间',
   align:"center",
   dataIndex: 'processEndTime'
  },*/
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "付款方式",
      field: 'paymentMethod',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"payment_method"
      },
      //colProps: {span: 6},
 	},
	{
      label: "到账状态",
      field: 'receiptStatus',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"receipt_status"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '收款日期',
    field: 'collectionDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款日期!'},
          ];
     },
  },
  {
    label: '款项类型',
    field: 'paymentType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"payment_type",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入款项类型!'},
          ];
     },
  },
  {
    label: '收款金额',
    field: 'amountCollected',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款金额!'},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '付款方式',
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"payment_method",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入付款方式!'},
          ];
     },
  },
  {
    label: '收款人',
    field: 'recipient',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款人!'},
          ];
     },
  },
  {
    label: '收款凭证',
    field: 'receiptVoucher',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款凭证!'},
          ];
     },
  },
  {
    label: '到账状态',
    field: 'receiptStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"receipt_status",
        type: "radio"
     },
  },
  {
    label: '订单号',
    field: 'orderNumber',
    component: 'Input',
  },
  {
    label: '扫码支付URL',
    field: 'scanCodePayUrl',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '交易状态',
    field: 'tradeState',
    component: 'Input',
  },
  {
    label: '交易状态描述',
    field: 'tradeStateDesc',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  collectionDate: {title: '收款日期',order: 0,view: 'date', type: 'string',},
  paymentType: {title: '款项类型',order: 1,view: 'radio', type: 'string',dictCode: 'payment_type',},
  amountCollected: {title: '收款金额',order: 2,view: 'number', type: 'number',},
  paymentMethod: {title: '付款方式',order: 3,view: 'radio', type: 'string',dictCode: 'payment_method',},
  recipient: {title: '收款人',order: 4,view: 'text', type: 'string',},
  receiptVoucher: {title: '收款凭证',order: 5,view: 'image', type: 'string',},
  receiptStatus: {title: '到账状态',order: 6,view: 'radio', type: 'string',dictCode: 'receipt_status',},
  processInitiator: {title: '流程发起人',order: 7,view: 'text', type: 'string',},
  processStatus: {title: '流程状态',order: 8,view: 'text', type: 'string',},
  processProgress: {title: '流程进展',order: 9,view: 'text', type: 'string',},
  processStartTime: {title: '流程启动时间',order: 10,view: 'datetime', type: 'string',},
  processEndTime: {title: '流程结束时间',order: 11,view: 'datetime', type: 'string',},
  orderNumber: {title: '订单号',order: 12,view: 'text', type: 'string',},
  scanCodePayUrl: {title: '扫码支付URL',order: 13,view: 'image', type: 'string',},
  tradeState: {title: '交易状态',order: 14,view: 'text', type: 'string',},
  tradeStateDesc: {title: '交易状态描述',order: 15,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
